package org.nemanjaristic.database.managers;

import org.nemanjaristic.database.managers.ManagerFactoryImpl.UserManager;

public abstract class ManagerFactory {

	/**
	 * Creates a standalone DAOFactory that returns unmanaged DAO beans for use
	 * in any environment Hibernate has been configured for. Uses
	 * HibernateUtil/SessionFactory and Hibernate context propagation
	 * (CurrentSessionContext), thread-bound or transaction-bound, and
	 * transaction scoped.
	 */
	
	/**
	 * Factory method for instantiation of concrete factories.
	 */
	@SuppressWarnings("unchecked")
	public static ManagerFactory instance(Class factory) {
		try {
			return (ManagerFactory) factory.newInstance();
		}
		catch (Exception ex) {
			throw new RuntimeException("Couldn't create DAOFactory: " + factory);
		}
	}
	
	public abstract UserManager getUserManager();
	
}
